Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

As far as I can see there is nothing in the GeoJSON standard to store styling information, i.e. line colours, thicknesses etc.

Am I missing something or is this just something that GeoJSON doesn't deal with?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

For GeoJOSN CSS is used to style your points,line, polygons with thickness & colour

{ 
    "type": "Feature",
    "geometry": {
    "type": "Polygon",
    "coordinates": [[
        [-180.0, 10.0], [20.0, 90.0], [180.0, -5.0], [-30.0, -90.0]
        ]]
    }
    "style:{
        //all SVG styles allowed
        "fill":"red",
        "stroke-width":"3",
        "fill-opacity":0.6
    }
    "className":{
        "baseVal":"highway_primary"
    }
}

http://wiki.openstreetmap.org/wiki/Geojson_CSS

share|improve this answer
    
This doesn't appear to be part of the GeoJSON spec. Is this a common implementation? –  Mr_Chimp Mar 29 '12 at 13:45
    
yes common common implementation, that works - GeoJOSN is a 'geospatial data interchange format' –  Mapperz Mar 29 '12 at 14:17
    
a bit of topic, but is this geoson_css related to carto mapbox.com/carto –  Francisco Puga Mar 29 '12 at 15:11
1  
That isn't a standard thing and each implementation is going to do this differently. –  Calvin May 17 '13 at 10:11
    
QGis (which uses GDAL under the hood) and geojsonlint.com, to name 2 examples, throw errors when using the "style" attribute. –  Marian Oct 17 '13 at 14:11
show 1 more comment

i think it is all about types of spelling and you can add more definition if you want. i dont think it is so important for not taking part in json spec...there is no limit for json object, only important thing is your json have to be valid for correct usage...

and i have checked Mapperz♦ geojson, it had some parse error in it.. and valid geojson:

{
    "type": "Feature",
    "geometry": {
        "type": "Polygon",
        "coordinates": [
            [
                [-180, 10],[20, 90],[180, -5],[-30, -90]
            ]
        ]
    },
    "style": {
        "stroke-width": "3",
        "fill-opacity": 0.6
    },
    "className": {
        "baseVal": "highway_primary"
    }
}

and the last thing to say is that you can check your geojson file whether valid or not from JSONLint which is a JSON Validator...

i hope it helps you

share|improve this answer
1  
I know it is possible to do it this way I just wondering whether other people implement it this way so as to maximise compatibility. –  Mr_Chimp Mar 29 '12 at 14:21
    
source is here - wiki.openstreetmap.org/wiki/Geojson_CSS –  Mapperz Mar 29 '12 at 15:39
add comment

GeoJSON doesn't deal with this. Any style information is going to depend on what the renderer is, Geojson CSS seams to target SVG but you also have Carto which targets mapnik, do remember that you can add extra fields to GeoJSON and it will still validate so none of these are invalid GeoJSON.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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