-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure out primary keys and update/alter #4
Comments
I'm pretty confident that the "id" property Fiona loads from the shapefile (which starts at 0 and increments from there) can be considered unique. It appears to be the value that is used to attach shapes in the I used the dbfread Python module to read the DBase file directly to see if it had a concept of an ID, and it doesn't appear to - suggesting that the index into the file is the only way to associate it with a shape:
Finally, the ESRI shapefile specification at https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf says the following: |
So... when importing a single shapefile into a single table it's safe for me to consider the But how about loading multiple shapefiles into the same table? The tool supports this at the moment:
But this won't work because of the duplicate primary keys. This could be solved with a mode where the primary key becomes a string with a unique prefix for each incoming shapefile. Maybe it does that automatically if you attempt to load multiple shapefiles into the same table? Or maybe there's an option for that - which would be a bit more obvious, but people would have to remember to use it.
|
Now using |
I just found a shapefile where the
https://data-usdot.opendata.arcgis.com/datasets/b0d0e777e2ad4b53803dbc0527c73d88_0 |
Hey @simonw, I am taking a look at this issue. I have resolved it locally using the Should I submit a PR for that? |
Yes please! That diff looks good - just needs a test and a sentence of documentation. |
geojson-to-sqlite
supports both--pk=
and--alter
options.I'm not sure if
--pk
makes sense for Shapefiles - they appear to have a unijque ID property that I could use, but I'm not certain if it is guaranteed to be present. It's been present in the files I've looked at so far.Adding tests that exercise
--alter
plus upserting data into existing tables would be worthwhile.The text was updated successfully, but these errors were encountered: