[mapserver-users] RE OGR csv - no field names

Jeff McKenna jmckenna at gatewaygeomatics.com
Mon Apr 25 14:51:33 PDT 2016


Actually I am able to use a .vrt with no field names:

<OGRVRTDataSource>
     <OGRVRTLayer name="occurrence">
         <SrcDataSource relativeToVRT="1">CSV:occurrence.txt</SrcDataSource>
         <GeometryType>wkbPoint</GeometryType>
         <LayerSRS>WGS84</LayerSRS>
         <GeometryField encoding="PointFromColumns" x="field_37" 
y="field_38"/>
     </OGRVRTLayer>
</OGRVRTDataSource>


and ogrinfo does find the geometry with that vrt:

INFO: Open of `occurrence.vrt'
       using driver `OGR_VRT' successful.

Layer name: occurrence
Geometry: Point
Feature Count: 75
Extent: (45.726390, -64.603440) - (45.726860, -64.575430)
Layer SRS WKT:
GEOGCS["WGS 84",
     DATUM["WGS_1984",
         SPHEROID["WGS 84",6378137,298.257223563


As for using those fields in a CLASSITEM etc in the mapfile layer, I am 
unable.


I am testing with MS4W 3.1.3 (MapServer 7.0.1).


-jeff




-- 
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/







On 2016-04-25 5:32 PM, Ian Walberg wrote:
> Thanks for the ideas.
>
> I think the vrt file needs the csv fields to have names unless I
> misunderstand.
>
> CSVT file – does this specify the column/field data type? Can the name
> be specified as well?
>
> Regards
>
> Ian
>
> *From:*Simon Mercier [mailto:smercier at mapgears.com]
> *Sent:* Monday, April 25, 2016 10:31 AM
> *To:* Steve.Toutant at inspq.qc.ca; Ian Walberg <ian.walberg at airborne.aero>
> *Cc:* mapserver-users at lists.osgeo.org; mapserver-users
> <mapserver-users-bounces at lists.osgeo.org>
> *Subject:* Re: [mapserver-users] RE OGR csv - no field names
>
> why not use a vrt file instead! http://www.gdal.org/drv_vrt.html
>
> <OGRVRTDataSource>
>      <OGRVRTLayer name="precipitation">
>          <SrcDataSource>precipitation.csv</SrcDataSource>
>          <GeometryType>wkbPoint</GeometryType>
>          <LayerSRS>EPSG:4326</LayerSRS>
>          <GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
>          <Field name="precipitation_mm" src="prec_mm"/>
>      </OGRVRTLayer>
> </OGRVRTDataSource>
>
>
> On 16-04-25 08:01 AM, Steve.Toutant at inspq.qc.ca
> <mailto:Steve.Toutant at inspq.qc.ca> wrote:
>
>     I don't know why LABELITEM 'filed_3' would not work in your case
>
>     You can try to specify column names by using a  .csvt file
>     http://www.gdal.org/drv_csv.html
>
>     Example:
>     https://anitagraser.com/2011/03/07/how-to-specify-data-types-of-csv-columns-for-use-in-qgis/
>
>
>
>
>     *Ian Walberg <ian.walberg at airborne.aero>
>     <mailto:ian.walberg at airborne.aero>@lists.osgeo.org*
>     Envoyé par : "mapserver-users"
>     <mapserver-users-bounces at lists.osgeo.org>
>     <mailto:mapserver-users-bounces at lists.osgeo.org>
>
>     2016-04-23 22:50
>
>     	
>
>     A
>
>     	
>
>     "mapserver-users at lists.osgeo.org"
>     <mailto:mapserver-users at lists.osgeo.org>
>     <mapserver-users at lists.osgeo.org>
>     <mailto:mapserver-users at lists.osgeo.org>
>
>     cc
>
>     	
>
>     Objet
>
>     	
>
>     [mapserver-users] OGR csv - no field names
>
>     	
>
>
>
>
>
>
>     Folks,
>
>     Can a csv file with no field names as the first row be used as an
>     OGR source?
>
>     GDAL creates dummy field names, are these passed to mapserver?
>
>     OGRFeature(USA-Hilton):652
>       field_1 (String) = -74.16958
>       field_2 (String) =  40.73526
>       field_3 (String) =  Penn Station
>
>     What do we need in the layer to make this work?
>
>     LABELITEM 'name' - this throws an error, 'field_3' does not seem to
>     work either.
>     CONNECTIONTYPE OGR
>     CONNECTION 'Stations.csv'
>
>     Thanks
>
>     Ian
>     _______________________________________________
>     mapserver-users mailing list
>     mapserver-users at lists.osgeo.org <mailto:mapserver-users at lists.osgeo.org>
>     http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
>
>
>     _______________________________________________
>
>     mapserver-users mailing list
>
>     mapserver-users at lists.osgeo.org <mailto:mapserver-users at lists.osgeo.org>
>
>     http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
>
> --
>
> simon mercier
>
> mapgears
>
> +1.418.476.7139 p101
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>





More information about the MapServer-users mailing list