Skip to main content
added 364 characters in body
Source Link
user30184
  • 69.1k
  • 4
  • 71
  • 125

YouI think that converting data into SpatiaLite in this case may be a good idea, even shapefiles do support simple BBOX queries with spatial index if spatial index is created (the .qix or .sbn/.sbx files) and you can use the same SQLrun your query with ogr2ogr also against the shapefile by using the SQLite SQL dialect. https://gdal.org/user/sql_sqlite_dialect.html.

You should get GeoJSON from ogr2ogr directly this way

ogr2ogr -f GeoJSON -sql "SELECT GEOMETRY FROM lotes WHERE ST_Area(ST_Intersection(ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100), lotes.geometry)) > 0 AND lotes.rowid IN (SELECT rowid FROM SpatialIndex WHERE f_table_name = 'lotes' AND search_frame = ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100))" output.json input.sqlite

You have something wrong in your query or in your data, or both. This is not correct

ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100)

EPSG:4326 coordinates are within range -90-> 90 and -180->180 degrees and a buffer that is 100 degrees wide means about 12000 kilometres. Check your data and what is the right coordinate system. You may get right results now but it is by chance.

You can use the same SQL with ogr2ogr this way

ogr2ogr -f GeoJSON -sql "SELECT GEOMETRY FROM lotes WHERE ST_Area(ST_Intersection(ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100), lotes.geometry)) > 0 AND lotes.rowid IN (SELECT rowid FROM SpatialIndex WHERE f_table_name = 'lotes' AND search_frame = ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100))" output.json input.sqlite

You have something wrong in your query or in your data, or both. This is not correct

ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100)

EPSG:4326 coordinates are within range -90-> 90 and -180->180 degrees and a buffer that is 100 degrees wide means about 12000 kilometres. Check your data and what is the right coordinate system. You may get right results now but it is by chance.

I think that converting data into SpatiaLite in this case may be a good idea, even shapefiles do support simple BBOX queries with spatial index if spatial index is created (the .qix or .sbn/.sbx files) and you can run your query with ogr2ogr also against the shapefile by using the SQLite SQL dialect. https://gdal.org/user/sql_sqlite_dialect.html.

You should get GeoJSON from ogr2ogr directly this way

ogr2ogr -f GeoJSON -sql "SELECT GEOMETRY FROM lotes WHERE ST_Area(ST_Intersection(ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100), lotes.geometry)) > 0 AND lotes.rowid IN (SELECT rowid FROM SpatialIndex WHERE f_table_name = 'lotes' AND search_frame = ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100))" output.json input.sqlite

You have something wrong in your query or in your data, or both. This is not correct

ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100)

EPSG:4326 coordinates are within range -90-> 90 and -180->180 degrees and a buffer that is 100 degrees wide means about 12000 kilometres. Check your data and what is the right coordinate system. You may get right results now but it is by chance.

Source Link
user30184
  • 69.1k
  • 4
  • 71
  • 125

You can use the same SQL with ogr2ogr this way

ogr2ogr -f GeoJSON -sql "SELECT GEOMETRY FROM lotes WHERE ST_Area(ST_Intersection(ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100), lotes.geometry)) > 0 AND lotes.rowid IN (SELECT rowid FROM SpatialIndex WHERE f_table_name = 'lotes' AND search_frame = ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100))" output.json input.sqlite

You have something wrong in your query or in your data, or both. This is not correct

ST_Buffer(ST_GeomFromText('POINT ( 339298.446287788 7391719.02695803 )', 4326), 100)

EPSG:4326 coordinates are within range -90-> 90 and -180->180 degrees and a buffer that is 100 degrees wide means about 12000 kilometres. Check your data and what is the right coordinate system. You may get right results now but it is by chance.