[R-sig-Geo] Conversion of a SpatialPolygonsDataFrame into a ESRI file

Bastien.Ferland-Raymond at mrnf.gouv.qc.ca Bastien.Ferland-Raymond at mrnf.gouv.qc.ca
Wed Mar 21 13:05:27 CET 2012


I Cristina,

I personally had success with the writeOGR of the rgdal package to export shape to ESRI.  I initially had the same error as you, which is not being able to get the dbf to display the data properly.  As Joona said, the problem was related to the field names.  In my case, if I recall well, I had dots in my fields names.  You should investigate that and try to get the simplest field names possible; short, no dots or other special characters, etc.

Good luck,

Bastien


Subject: Re: [R-sig-Geo] Fwd: Re: Conversion of a
        SpatialPolygonsDataFrame into a ESRI file
Message-ID: <4F687F59.90104 at cs.helsinki.fi>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi Cristina,

Which version of ArcGIS are you using? The dbf-format is notorious for
mangling the field names longer than 10 characters. I can't imagine how
this might prevent the attribute table from showing, but you never know.

In ArcGIS, you could just try exporting the shapefile into a new file
(shapefile or geodatabase feature layer) and see if the new file behaves
better.

Joona

On 03/20/2012 02:37 PM, Cristina Silva wrote:
> Sorry, I didn't reply for the list.
>
> Cristina
>
> -------- Original Message --------
> Subject:      Re: [R-sig-Geo] Conversion of a SpatialPolygonsDataFrame into
> a ESRI file
> Date:         Tue, 20 Mar 2012 12:15:46 +0000
> From:         Cristina Silva<csilva at ipimar.pt>
> To:   P?nar Aslantas Bostan<aslantas at metu.edu.tr>
>
>
> Hi Pinar,
>
> The problem is not to get the data, this can be done directly with
> write.csv or write.table. I was looking for a package/function to
> export the whole spatial object to a ESRI shapefile with all the files
> needed (.shp, .shx, .prj and .dbf). With writeOGR I can do this but
> the resulting .dbf file is not read properly, although the data are
> there.
>
> Thanks anyway.
>
> Cristina
>
> On 20/03/2012 11:36, P?nar Aslantas Bostan wrote:
>>   Dear Cristina,
>>
>>   For this purpose I use "write.table" function.
>>
>>   my code is this;
>>
>>   write.table(dem, file="D:\\Data\\dem_outputs.txt", quote = TRUE, dec = ".",
>>   qmethod = c("escape", "double"))
>>
>>   # "dem" is SpatialPixelsDataFrame in my study.
>>
>>   then you can add your data as txt file in ArcGis.
>>
>>   I hope this helps.
>>
>>   Best wishes,
>>   Pinar
>>
>>
>>   -----Original Message-----
>>   From: r-sig-geo-bounces at r-project.org
>>   [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Cristina Silva
>>   Sent: Tuesday, March 20, 2012 1:11 PM
>>   To: r-sig-geo at r-project.org
>>   Subject: [R-sig-Geo] Conversion of a SpatialPolygonsDataFrame into a ESRI
>>   file
>>
>>   Dear all,
>>
>>   I need to export a SpatialPolygonsDataFrame to a shapefile to  be read by
>>   ArcGIS. I have used several packages and functions to do this with different
>>   results.
>>
>>   1) with maptools, function writePolyShape: The file .prj is not
>> created
>>
>>   2) with spsurvey, function sp2shape: Doesn't work, gives the following
>>   message "Error: Opening .prj file in C function
>> writeShapeFilePolygon"
>>
>>   3) with rgdal, function writeOGR:
>>
>>      * with data projected (transforming longlat into utm) or not (longlat:
>>        the file is read by ArcGIS. However, when I try to open the
>>        Attributes table, it gives the message that could not load the data
>>        from the data source, suggests to refresh (which is not possible)
>>        and opens an empty table, although having the number of columns and
>>        lines of the data. Looking for the info of each polygon in the map,
>>        the data are displayed for each individual record. So, the data
>>        exist but are not acessible from the Attributes Table.
>>      * To display the Attributes Table, I had to convert the .dbf file in
>>        .csv and export again as a .dbf.
>>
>>   Is there any better way to make this conversion?
>>
>>   Cristina
>>
>>   --
>>   ------------------------------------------
>>   Cristina Silva
>>   INRB/L-IPIMAR
>>   Unidade de Recursos Marinhos e Sustentabilidade Av. de Brasmlia, 1449-006
>>   Lisboa Portugal
>>   Tel.: 351 21 3027096
>>   Fax: 351 21 3015948
>>   csilva at ipimar.pt
>>
>>
>>      [[alternative HTML version deleted]]
>>
>>
>
>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list