Open spatialhast opened 6 years ago
Seeing this issue for:
cc/ @mourner @geohacker @batpad
I did some more digging today. So, the mbtiles-extracts
library generates
which-polygon
npm package to make a decision about whether or not to extract features from the tile<>polygon intersectionIn several cases, the unprojected [lng, lat] may not be within the polygons in the geojson, even though the polygon intersects part of the tile. Here are a few polygons (all from the geojson referenced above) where the unprojected [lng, lat] (from the tiles in the mbtiles tileset referenced above) is outside the polygon but within the bounding box constricting the polygon:
Full set of polygons and unprojected [lng, lat] points that are excluded as a result of a bug somewhere in the data/code here
Why is this the case? Is there a better way to handle this? Is this a bug in the mbtiles-extracts
library or the mbtiles file or the geojson file?
cc also @answerquest, who helped me validate my geojson to make sure that it is following the right hand verification rule, a fix that taught me a lot about geojsons and GIS trivia, but wasn't the solution for the above problem. : )
One way you could try to fix it is replacing single-point whichPolygon query with a bbox one, like described in the readme at the bottom (query.bbox
).
One way you could try to fix it is replacing single-point whichPolygon query with a bbox one, like described in the readme at the bottom (query.bbox).
👋 @mourner Yes I was considering this. So, if I do this, I will be checking the intersection of:
Correct?
@arunasank this line currently queries the center of the tile. Instead, you would unproject 2 corners of the tile ([x, y], [x + 1, y + 1]
), make a bounding box out of this ([minLng, minLat, maxLng, maxLat]
), and use that as a bbox query (to compare against polygons in the index).
@mourner got it, that clarifies things. I'll submit a PR. Thanks for the map math! ♥️
I opened a new issue for the problem I was seeing at https://github.com/mapbox/mbtiles-extracts/issues/12, which seems to be different from the OP's issue.
The solution discussed above does not resolve the OP's issue.
For extract parts of an mbtiles I use command:
mbtiles-extracts adria.mbtiles polygon3857.geojson admin
but it return nothing.gdalinfo
input mbtiles file:GeoJSON file in EPSG:3857 coordinate system. Source files: mbtiles - https://www.dropbox.com/s/amngyovs64292e2/adria.mbtiles?dl=0, geojson - https://www.dropbox.com/s/fvj6rwaixzy4ah6/polygon3857.geojson?dl=0
There is any spesified requirements for input mbtiles and geojson file?