Comments (4)
Hi!
The syntax of the web console and the command line are slightly different. You can run "history" in the web console to translate your console commands to their command line equivalents, but you'll probably have to change the paths of the input files, because the web console doesn't know where on your computer the input files came from.
I can see that keys='[latitude,longitude],gasht_name'
in your example is wrong. The keys
option is used when joining two layers by matching data values in so-called "key" fields. I think you want to do a different kind of join, called a spatial join, which doesn't use the keys
option.
I think the solution will look more like this:
mapshaper -i Tabriz_houses_inf.csv \
-points \
-join codgashttabriz.json fields=gasht_name \
-o output.geojson
Good luck!
from mapshaper.
Hi @mbloch, thank you for your attention. Here are the steps I followed:
Step One: Running history in the web console:
mapshaper -i codgashttabriz.shp
-i Tabriz_houses_inf.csv
-points x=longitude y=latitude
-target codgashttabriz
-proj wgs84
-clip codgashttabriz
-join codgashttabriz target='Tabriz_houses_inf' fields='gasht_name'
-o target= format=dsv
Step Two: Writing in a python file:
mapshaper_commands = [
["mapshaper", "-i", shp_file],
["mapshaper", "-i", csv_file],
["mapshaper", csv_file, "-points", "x=longitude", "y=latitude"],
["mapshaper", shp_file, "-target", shp_file[:-4]],
["mapshaper", shp_file, "-proj", "wgs84"],
["mapshaper", csv_file, "-clip", shp_file[:-4]],
["mapshaper", '-join', shp_file[:-4], f'target={csv_file[:-4]}', 'fields=gasht_name'],
["mapshaper", csv_file, "-target", csv_file[:-4], '-o', 'target= format=dsv']
]
for line in mapshaper_commands:
subprocess.run(line)
The output is:
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
[points] 2,402 of 3,586 points are null
[wkt] unhandled parameter: Auxiliary_Sphere_Type
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
Error: [clip] File not found (codgashttabriz)
Run mapshaper -h to view help
Error: [join] Missing layer: Tabriz_houses_inf
Run mapshaper -h to view help
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
Error: [o] Missing layer: format=dsv
Run mapshaper -h to view help
Step Three: I changed line ["mapshaper", csv_file, "-clip", shp_file[:-4]] to ["mapshaper", csv_file, "-clip", shp_file] , which resolved the related error. The output is as:
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
[points] 2,402 of 3,586 points are null
[wkt] unhandled parameter: Auxiliary_Sphere_Type
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
[wkt] unhandled parameter: Auxiliary_Sphere_Type
Error: [join] Missing layer: Tabriz_houses_inf
Run mapshaper -h to view help
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
Error: [o] Missing layer: format=dsv
Run mapshaper -h to view help
Step Four: I encountered issues with the join command not recognizing Tabriz_houses_inf or Tabriz_houses_inf.csv. I tried changing the line related to join as ["mapshaper", '-join', shp_file[:-4], f'target={csv_file}', 'fields=gasht_name'], but I received the following error:
Error: [join] Missing layer: Tabriz_houses_inf.csv
Run mapshaper -h to view help
[i] Auto-detected number fields: code, unit_price, unit_price_En, elevator, parking, warehouse, meterage, latitude, longitude
Error: [o] Missing layer: format=dsv
I'm unsure about the last two lines and how to resolve them. I apologize for the lengthy text. I wanted to provide all the necessary details.
from mapshaper.
I suggest first getting your sequence of commands to work in an interactive shell, like bash
. I gave you a set of shell commands to try in my earlier comment. Once you have something like that working, then you can port it to Python.
Your process has multiple steps -- I often start simple, with one editing command followed by a -o
or -info
command to check that the result is what I want. Then I add more commands until I have an entire pipeline of commands.
The first problem I see with your Python script is that you are splitting up your work into multiple subprocesses. The entire sequence of mapshaper commands should be contained in a single Python subprocess. Otherwise the results from one command will not be passed on to the next command. Files are not modified unless they are overwritten using the -o
command.
from mapshaper.
You were right @mbloch, I should have written everything in one command. My problem is solved. I really enjoyed mapshaper.
from mapshaper.
Related Issues (20)
- light blue paths and performance HOT 3
- Memory usage almost 4x size of input geojson file HOT 4
- Filter lines still create polygons HOT 5
- When hovering mouse over feature and scrolling, fill color freaks out HOT 1
- Point layers and data layers do not show up HOT 2
- Cannot convert between WGS84 and Webmercator after converting and saving data as EPSG:3857. HOT 3
- Error on simplifying GeoJSON file HOT 11
- Javascript error related to polygon editing causes GUI to crash HOT 1
- There is an issue when you import a shapefile HOT 2
- Clip command removes Features visually but not from exported file. HOT 4
- Sticky hand HOT 1
- snap effects multiples layers HOT 1
- geojson from points HOT 2
- Export failed Export failed for an unknown reason HOT 3
- topojson files in power bi HOT 2
- Problem in drawing polygon and importing snapshot file HOT 4
- Export to Shape File Not working HOT 12
- Bug: can't open snapshot file I created on mapshaper.org HOT 3
- Bug: copy as GeoJSON doesn't copy GeoJSON HOT 1
- filter-slivers remove-empty bug
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapshaper.