Skip to content
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

GeoJSON as alternative to shapefiles #630

Merged
merged 3 commits into from
Jan 1, 2024
Merged

GeoJSON as alternative to shapefiles #630

merged 3 commits into from
Jan 1, 2024

Conversation

systemed
Copy link
Owner

@systemed systemed commented Dec 30, 2023

This enables GeoJSON files to be used in exactly the same way that shapefiles are.

Also refactor shapefile processing into its own class.

@systemed systemed mentioned this pull request Dec 30, 2023
18 tasks
@cldellow
Copy link
Contributor

This and b278569 are very cool together. It came just in time to solve a problem I had been deferring solving.

Problem: I'm building a map where national/state parks are treated specially -- different features are emphasized vs the broader map. I still want the broader map to have these features in order to orient the user, but in the broader map, the features might only appear at higher zooms, or are styled with less contrast.

Solution with this PR:

  1. Have a one-off Lua profile that emits only national/state parks polygons

  2. cldellow@0a61877 extends this branch so you can do --output parks.geojson. When writing, it will dump any materialized OSM multipolygons to GeoJSON.

  3. Have a "real" Lua profile that consumes parks.geojson so that it can do Intersects(...) queries, and either adjust the output zooms, or emit an attribute that a future style rule can target.

My real profile does have this hacky bit in its config file:

{
    "layers": {
        "parks": {
            "minzoom": 15,
            "maxzoom": 15,
            "source": "../parks.geojson",
            "index": true
        },
        ...
    },
    "settings": {
        "basezoom": 14
        ...

Since I'm only using the parks layer for spatial queries, I set its minzoom to a zoom greater than my map's basezoom to prevent it from being materialized into the output.

This is a bit of an OSM ouroboros...but it seems to work? Maybe it'll fall over if I scale it up.

(Maybe there is a better way to do this? I have close to zero familiarity with the GIS toolchain outside of OSM-related tools.)

@cldellow
Copy link
Contributor

Ah, related: when shp/geojson files are configured to be indexed, it looks like StoreGeometry needs a lock to avoid corrupting indexedGeometries/indices[layerName]/indexedGeometryNames

@systemed
Copy link
Owner Author

Good spot - I’ve got a couple of tweaks including that which I’ll push tomorrow.

@systemed
Copy link
Owner Author

systemed commented Jan 1, 2024

Small push which fixes threading and another couple of issues.

(Maybe there is a better way to do this? I have close to zero familiarity with the GIS toolchain outside of OSM-related tools.)

That's quite ingenious! Not particularly a priority but we could perhaps integrate that as a separate --dump option (rather than overloading --output which is intended for tile output).

The most common way to get individual features out of OSM in GeoJSON format is by using Overpass Turbo. But I'd guess you could also do it using osmium extract and then ogr2ogr.

@systemed systemed merged commit 65829e4 into master Jan 1, 2024
5 checks passed
@systemed systemed deleted the geojson branch January 1, 2024 23:08
@cldellow
Copy link
Contributor

cldellow commented Jan 2, 2024

Thanks for the pointers to Overpass and ogr2ogr.

Yes, this is fairly removed from Tilemaker's core reason for being. I'll let it kick around in my repo while I get a feel for it.

#556 is another user who might be served by it (or something similar to it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants