GIS: Converting multi polygons to multiple features - gis

I am involved in a GIS project. I have a base map file (shape file) that contains the road layer for a large portion of a town. The problem is that the shape file contains only two features each containing around 500000 points each. The features are multipolygons containing a large no of polygons inside. I wish to convert it to numerous features each containing not more than one polygon. Is it possible? If yes, how?

Seems like what you have here is a multi-part feature. If you are using ArcGIS, you need to add the advance editor toolbar in your arcmap. Start an editing session and use the explode multi-part feature tool and then you will have one geometry for each record.

If you have connectivity information (e.g. you have polygons and not just points) it's not too tough to do a decent job of polygon reduction.
What I've done in the past consisted of two steps.
Any vertex that is surrounded by polygons, all of which are coplanar, can be removed. I did this by "sliding" the vertex to a neighbor vertex, that neighbor getting all of the test vertex's neighbors and any triangles that become degenerate (e.g. any triangles shared between the two vertices) were removed.
Any vertex which has two edges leaving opposite one another, where the polygons on either side are either completely nonexistent or are coplanar can also be similarly collapsed into a neighbor vertex, but obviously only one that is along one of the parallel edges.
note-
Two polygons are coplanar if they share at least one point in common and if they have the same normal. Since the candidate polygons are always attached to the candidate vertex, you just need to compare polygon normals. The normal can be computed by taking the cross product of two of the edges of the polygon.

Related

MySQL Spatial Object for multiple polygons that may or may not be connected

I have a set of of polygons. Sometimes they are completely disconnected (like separate patches). Other times, two sides of two polygons may touch each other (when the polygons are adjacent like on a chess board). The polygons never cross each other. In other words, their intersection is always empty.
I need to check if a point is contained in any one of those polygons. Is there a way I can build a single geometry using these polygons and check if the point is in it?
Currently I'm building a long WHERE close with OR conditions and do something like the below:
st_contains(st_GeomFromText('POLYGON(("+polygon+"))'), st_GeomFromText(CONCAT('POINT()')))
Thanks.

How to separate/partition polygons into existing regions?

I'm facing a problem regarding "partitioning"/subsetting polygons into regions (bigger polygons) so that each region should have disjoint meaningful elements.
For example, we have the following regions/polygons. At a given time, we know only the form of one region (let's say R1 for now).
It is clear that L3 would belong to R1.
How about L1, L2 and P1?
I thought about creating bounding boxes around them and check if the South-East coordinate( minX and minY) belongs to R1.
In this way L1 would belong to R2, even though it doesn't even crosses R2.
Do you have any concrete idea what I should look into for these sort of algorithms or how to solve this space separation problem?
If your regions and polygons are all described as polygons (discrete sequences of vertices), you can resort to the available polygon clipping techniques.
In particular, have a look at the Sutherland–Hodgman and Weiler–Atherton techniques.
Some optimization is possible if preprocessing of the windows is allowed (when there are many subject polygons for the same windows), using scanline techniques. This is a little more sophisticated.
The case of line segment entities is a little easier.

Tabelau geographical heatmap and overlaying data from two different datasets

Now I'm trying to overlay latitude and longitudinal points from two different data sets, resulting in two different markers for each one on a geographical map. There is no relationship between the two data sets. Tableau doesn't seem to be able to accomplish this directly. I don't want to group the data at all, just plot the lat and lon points. Any suggestions?
I would also like one of the datasets above to be a heatmap, i.e. each data point plotted has its intensity correlated to the dimension. Besides the overlaying problem above, accomplishing a geographical heat map alone is not working for me. My geographical heat map by latitude and longitudinal points is not conveying the information I want. The lighter color marks are on top of the darker color marks. However, I want the darker color marks to be in front. How do I achieve this?
Would Google Maps or Fusion Tables be a better option for me?
I solved this problem by combining the two datasets into one using UNION ALL, making sure to add an extra column with a descriptor designating the originating source (i.e., which of the two datasets). I then set up a calculated field to determine what data to visualize and how to visualize it.
As regards to the heatmap, the solution was to bin the data and then sort it when plotting. Without binning, sorting appears not possible using Tableau.
I took a look at Google Maps and Fusion Tables, but the functionality and visual aesthetics are currently not at the Tableau level.

Mysql two points to be checked if they are in rectangles

I'm in a process of developing an application and I would appreciate some help regarding an idea how to store data in mysql table.
I have two points - point A and point B which are start and end point.
I've already wrote some php function that will create rectangles similar to:
http://googlegeodevelopers.blogspot.com/2010/05/search-along-route-made-easy-with.html
However depending on the route and radius it generates different amount of rectangles. What is the best way to save those rectangles into the database, so later I can query the DB and check if another two points (start/end) are in any of those rectangles.
Can you give me an example?
The easiest way to do it is to store your rectangles as polygons, per
http://dev.mysql.com/doc/refman/4.1/en/polygon-property-functions.html
You can then use MBRIntersects to figure out if they intersect (or use MBRWithin or MBRContains, if you'd prefer), per
http://dev.mysql.com/doc/refman/5.1/en/functions-for-testing-spatial-relations-between-geometric-objects.html#function_mbrintersects
For funky-shaped polygons, this isn't adequate, but the MBR (minimum bounding box) of a rectangular bounding box will be exactly the same as the rectangle itself.

How to very efficiently assign lat/long to city boundary described by shape?

I have a huge shapefile of 36.000 non-overlapping polygones (city boundaries). I want to easily determine the polygone into which a given lat/long falls. What would the best way given that it must be extremely computationaly efficient ?
I was thinking of creating a lookup table (tilex,tiley,polygone_id) where tilex and tiley are tile identifiers at zoom levels 21 or 22. Yes, the lack of precision of using tile numbers and a planar projection is acceptable in my application.
I would rather not use postgres's GIS extension and am fine with a program that will run for 2 days to generate all the INSERT statements.
Insert statements into what? Are you using a different spatial database or some other database? If you are willing to use python, C, or Java you could use shapely, GEOS, or JTS to write some custom code to do what you want rather simply.
In python use this lib to open the shapefile
http://indiemaps.com/blog/2008/03/easy-shapefile-loading-in-python/
then shapely
http://gispython.org/shapely/docs/1.0/manual.html#contains
to test containment
For Java use Geotools which also includes JTS.
Sounds like you want a BSP tree. Basically you divide the area into smaller and smaller polygons in a tree like fashion.
The advantage is that you don't need to compare coordinates with every polygon later on. That makes it a very fast way to find the correct polygon.