3

I have a SpatiaLite dataset (with the projection EPSG:4326) with the following content:

enter image description here

I'd like to find a way of dividing this polygon into multiple smaller polygons... Something like the following:

enter image description here

Is there any way of creating a grid on my polygon and then dividing it into multiple smaller polygons? I've checked the SpatiaLite documentation and I found the SquareGrid function... But if I try running select SquareGrid(GEOMETRY, 0.00001) from dataset, the spatialite-gui interface will crash. I'm probably missing something about how to use this function... Also, I'm not sure if the SquareGrid function will solve my problem as I expect it to be solved. Is it possible to do on SpatiaLite? Can I split a polygon into multiple smaller polygons inside a predefined grid?

1
  • If you are using ArcMap you could use the split tool?
    – Hornbydd
    Aug 9, 2021 at 22:03

2 Answers 2

2

If it is not essential to use a regular grid for splitting then the latest SpatiaLite http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html has a function ST_Subdivide for the job. It works in the same way than ST_Subdivide in PostGIS https://postgis.net/docs/ST_Subdivide.html.

Divides geom into many parts until each part can be represented using no more than max_vertices. If the optional argument max_vertices is not explicitly specified a limit of 128 vertices is implicitly assumed. NULL will be returned on invalid arguments.

2

This issue is due to the decimal parameter is expressed in degrees as the SRC is geographic (EPSG:4326) instead of meter if you were using a UTM CRS.

The problem is, if the Earth would really be a Sphere :)) (Actually it is a geoid, not a sphere, but never flat) the average diameter would be approximately 12.742 Km, which means almost 35.400m for each degree.

As you were trying to slice Earth's surface into segments of 0.00001 degrees each piece would measure 35cm on average. Imagine how big it is, actually is the almost Point Cloud ALS precision.

I would suggest you use UTM to gain precision in this scale and work with a regular grid in Meters. If you'll work in Degrees you have to consider all of your grids in different latitudes will have different sizes. But even if, you want to keep working with Geographic CRS try to use something higher than 0.04

I did it here, using SIRGAS 2000 UTM 23S (EPSG:31983) and with 1000 meter grid and the result is like above:

enter image description here

The SQL line of code:

select ogc_fid as id, SquareGrid(GEOMETRY, 1000) as geom from represas
2
  • 1
    Hi, one degree of latitude measures approximately 111 kilometers. Do your query work fine in the spatialite-gui if for example it said 0.01 instead of 1000, applied on the original dataset? Aug 10, 2021 at 15:11
  • Nice, it works now... However, I've realized that the SquareGrid function only partially solves my problem since it only creates a grid of squared polygons above my data... The complete solution would still require a way of splitting one geometry from another. The ST_Subdivide function ended up working better for my particular problem... But thanks for the detailed response :)
    – raylight
    Aug 11, 2021 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.