Opened 17 years ago

Closed 17 years ago

#1575 closed defect (fixed)

Need to limit KML Polygon Complexity

Reported by: warmerdam Owned by: Mateusz Łoskot
Priority: normal Milestone: 1.4.2
Component: OGR_SF Version: unspecified
Severity: normal Keywords: kml
Cc: warmerdam, didge

Description (last modified by warmerdam)

Bryan reports:

""" I solved this problem with some help from Google:

http://groups.google.com/group/kml-support-getting-started/browse_thread/thread/e6995b8073e69c41

The problem turned out to be that Google has a limit on the number of vertices in a polygon. My solution was to dump the dataset into postgis and simplify the large polygons. I did something like this:

ogr2ogr -sql "select admin, case when area(the_geom) > 3000000000 then transform(simplify(the_geom, 4), 4030) else transform(simplify(the_geom, 0.01), 4030) end from utlanduse" -f kml out.kml PG:"host=localhost user=xxx dbname=statewide password=xxx"

The simplified polygons display without a problem in Google Earth. """

I think perhaps that the KML driver should warn, or include an option to automatically simplify features to be legal with google earth.

Change History (6)

comment:4 by warmerdam, 17 years ago

Description: modified (diff)

comment:5 by warmerdam, 17 years ago

Cc: Mateusz Łoskot didge added

comment:6 by Mateusz Łoskot, 17 years ago

I think it's worth to quote some notes from the polygon displays with vertical stripes thread here:

ManoM:

You seem to be running up against a too-many coordinate problem.
Google Earth does have limits on the number of coordinates in a single
geometry. It looks like you're hitting the limit by having too many
combined coordinates. One thing you might look into is line smoothing,
taking way coordinates. Also, you have your coordinates set at a very
high level of precision. Anything out past 6 decimal places is
essentially indistinguishable. I don't know if that's having an
effect, but it might help with smoothing.

Bryan:

What is Google Earth's limit on the number of coordinates in a single
geometry? 

ManoM:

There's no hard limit on the number of coordinates. Many factors,
apparently go into it.

According my understanding of this explanation, there is not hard limits but it's more like a judgement that your geometry is too big.

So, it seems it's not possible to just check number of coordinates and warn user that it will probably can not be displayed properly in the GE.

For me, the idea of line/polygon simplification on request is very reasonable. The problem here is to define how user is supposed to use it. What factors are required as input, etc.? Many users do not know what's a geometry simplification, they may be confused if they will be asked for tolerance factor.

comment:7 by warmerdam, 17 years ago

Cc: warmerdam added; Mateusz Łoskot removed
Milestone: 1.5.01.4.2
Owner: changed from warmerdam to Mateusz Łoskot

Mateusz,

Could you add some notes in the kml driver user docs warning that very complex features may not render properly in GE? I don't think we should try and do simplification in the driver given the vagueness of the issues.

comment:8 by Mateusz Łoskot, 17 years ago

Status: newassigned

comment:9 by Mateusz Łoskot, 17 years ago

Resolution: fixed
Status: assignedclosed

I updated KML driver documentation with short note about the limitation and potential problem.

Note: See TracTickets for help on using tickets.