tpk files

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

tpk files

Martocas
Hi,

I would like to open (and use) a 'tpk' file from arcgis in r.
For example:
https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6

I tried raster and sf package, but no luck.

Any ideia if we can do this in r?

Thank you very much in advance,

Best wishes,
M.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

Barry Rowlingson-3
What did you try? The instructions at the top say:

"Download 3.3GB tile package and rename extension from .tpk to .zip.
Extract to get EMU.gpkg"

If that's a valid GeoPackage then `sf` should be able to read it. Not sure
what might be in the geopackage though, "tile package" sounds like rasters,
but GeoPackages are generally vector...

I'll try in five minutes when all 3.3Gb have downloaded....

On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
wrote:

> Hi,
>
> I would like to open (and use) a 'tpk' file from arcgis in r.
> For example:
>
> https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
>
> I tried raster and sf package, but no luck.
>
> Any ideia if we can do this in r?
>
> Thank you very much in advance,
>
> Best wishes,
> M.
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

Shaun Walbridge
I think the issue is, most GDAL installations don't have the Geopackage raster driver [1] installed by default, which lists "Needs libsqlite3 (and any or all of PNG, JPEG, WEBP drivers)" for it to be available. At least on my Homebrew installation of GDAL, this driver wasn't built out of the box. If you rebuild GDAL with this additional driver, or find a prebuilt binary which has it, it should be able to open. A simple test is if `gdalinfo EMU.gpkg` returns information about the dataset outside of R.

1. https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=

On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]> wrote:

    What did you try? The instructions at the top say:
   
    "Download 3.3GB tile package and rename extension from .tpk to .zip.
    Extract to get EMU.gpkg"
   
    If that's a valid GeoPackage then `sf` should be able to read it. Not sure
    what might be in the geopackage though, "tile package" sounds like rasters,
    but GeoPackages are generally vector...
   
    I'll try in five minutes when all 3.3Gb have downloaded....
   
    On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
    wrote:
   
    > Hi,
    >
    > I would like to open (and use) a 'tpk' file from arcgis in r.
    > For example:
    >
    > https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
    >
    > I tried raster and sf package, but no luck.
    >
    > Any ideia if we can do this in r?
    >
    > Thank you very much in advance,
    >
    > Best wishes,
    > M.
    >
    >         [[alternative HTML version deleted]]
    >
    > _______________________________________________
    > R-sig-Geo mailing list
    > [hidden email]
    > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
    >
   
    [[alternative HTML version deleted]]
   
    _______________________________________________
    R-sig-Geo mailing list
    [hidden email]
    https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
   


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

Martocas
In reply to this post by Martocas
Hi Barry,

Thank you so much for your quik reply!
Yep, I tried that... after downloading, changing the name and decompressing
(it becomes 27GB), then I was not able to read it with r.
I will try again then.

Cheers,
M.

PS: now, it is giving me an error:

Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  std::bad_alloc
In addition: Warning message:
In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
  GDAL Error 1: In GetNextRawFeature(): sqlite3_step() : disk I/O error
>

Barry Rowlingson <[hidden email]> escreveu no dia quinta,
11/04/2019 à(s) 16:39:

> What did you try? The instructions at the top say:
>
> "Download 3.3GB tile package and rename extension from .tpk to .zip.
> Extract to get EMU.gpkg"
>
> If that's a valid GeoPackage then `sf` should be able to read it. Not sure
> what might be in the geopackage though, "tile package" sounds like rasters,
> but GeoPackages are generally vector...
>
> I'll try in five minutes when all 3.3Gb have downloaded....
>
> Barry
>
>
>
>
> On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
> wrote:
>
>> Hi,
>>
>> I would like to open (and use) a 'tpk' file from arcgis in r.
>> For example:
>>
>> https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
>>
>> I tried raster and sf package, but no luck.
>>
>> Any ideia if we can do this in r?
>>
>> Thank you very much in advance,
>>
>> Best wishes,
>> M.
>>
>>         [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> [hidden email]
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>

--
Marta M. Rufino (auxiliary researcher)

*____________________________________________________*MARE - Marine and
Environmental Sciences Centre
Faculty of Sciences, University of Lisbon
Campo Grande, 1749-016 Lisboa,
Portugal
Tel: + 351 21 750 00 00, extension: 22576

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

Roger Bivand
Administrator
Briefly, could you use the proxy interface in stars and subset without reading the whole object? I'm not able to check now, but if the data are raster layers, perhaps temporal, stars may be helpful.

Roger

Roger Bivand
Norwegian School of Economics
Bergen, Norway



Fra: Marta Rufino
Sendt: torsdag 11. april, 17.58
Emne: Re: [R-sig-Geo] tpk files
Til: Barry Rowlingson
Kopi: r-sig-geo


Hi Barry, Thank you so much for your quik reply! Yep, I tried that... after downloading, changing the name and decompressing (it becomes 27GB), then I was not able to read it with r. I will try again then. Cheers, M. PS: now, it is giving me an error: Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : std::bad_alloc In addition: Warning message: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL Error 1: In GetNextRawFeature(): sqlite3_step() : disk I/O error > Barry Rowlingson escreveu no dia quinta, 11/04/2019 à(s) 16:39: > What did you try? The instructions at the top say: > > "Download 3.3GB tile package and rename extension from .tpk to .zip. > Extract to get EMU.gpkg" > > If that's a valid GeoPackage then `sf` should be able to read it. Not sure > what might be in the geopackage though, "tile package" sounds like rasters, > but GeoPackages are generally vector... > > I'll try in five minutes when all 3.3Gb have downloaded.... > > Barry > > > > > On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino > wrote: > >> Hi, >> >> I would like to open (and use) a 'tpk' file from arcgis in r. >> For example: >> >> https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6 >> >> I tried raster and sf package, but no luck. >> >> Any ideia if we can do this in r? >> >> Thank you very much in advance, >> >> Best wishes, >> M. >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> R-sig-Geo mailing list >> [hidden email] >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >> > -- Marta M. Rufino (auxiliary researcher) *____________________________________________________*MARE - Marine and Environmental Sciences Centre Faculty of Sciences, University of Lisbon Campo Grande, 1749-016 Lisboa, Portugal Tel: + 351 21 750 00 00, extension: 22576 [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

edzer
In reply to this post by Shaun Walbridge
It's a 30 Gb 3D point file:

$ ogrinfo EMU.gpkg
INFO: Open of `EMU.gpkg'
      using driver `GPKG' successful.
1: EMU_Master (3D Point)

@Shaun: homebrew seems to be supported neither by apple, nor by CRAN, so
you are a bit on your own there. Have you tried the CRAN binary packages
using GDAL?

In any case, the windows binary does (should) support gpkg, see
https://github.com/rwinlib/gdal2

Trying to read this file into R with sf::st_read will require a lot of
RAM, or some strategy to read in parts only.

On 4/11/19 5:52 PM, Shaun Walbridge wrote:

> I think the issue is, most GDAL installations don't have the Geopackage raster driver [1] installed by default, which lists "Needs libsqlite3 (and any or all of PNG, JPEG, WEBP drivers)" for it to be available. At least on my Homebrew installation of GDAL, this driver wasn't built out of the box. If you rebuild GDAL with this additional driver, or find a prebuilt binary which has it, it should be able to open. A simple test is if `gdalinfo EMU.gpkg` returns information about the dataset outside of R.
>
> 1. https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=
>
> On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]> wrote:
>
>     What did you try? The instructions at the top say:
>    
>     "Download 3.3GB tile package and rename extension from .tpk to .zip.
>     Extract to get EMU.gpkg"
>    
>     If that's a valid GeoPackage then `sf` should be able to read it. Not sure
>     what might be in the geopackage though, "tile package" sounds like rasters,
>     but GeoPackages are generally vector...
>    
>     I'll try in five minutes when all 3.3Gb have downloaded....
>    
>     On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <[hidden email]>
>     wrote:
>    
>     > Hi,
>     >
>     > I would like to open (and use) a 'tpk' file from arcgis in r.
>     > For example:
>     >
>     > https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
>     >
>     > I tried raster and sf package, but no luck.
>     >
>     > Any ideia if we can do this in r?
>     >
>     > Thank you very much in advance,
>     >
>     > Best wishes,
>     > M.
>     >
>     >         [[alternative HTML version deleted]]
>     >
>     > _______________________________________________
>     > R-sig-Geo mailing list
>     > [hidden email]
>     > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
>     >
>    
>     [[alternative HTML version deleted]]
>    
>     _______________________________________________
>     R-sig-Geo mailing list
>     [hidden email]
>     https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
>    
>
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

pEpkey.asc (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

Barry Rowlingson-3
QGIS could "read" it pretty smartly, only loading in the bits in the
current view extent, and doing the loading in a separate thread so the GUI
was still active.

Marta has told me that she only needs the surface layer points - the X Y
and Z coordinates are duplicated as attributes so I think a selection of
Z=0 (or something) might make a small enough subset to read into R
directly. This might be doable via the `query` option of `st_read`, or
failing that a "select" in SQLite3 and dumping the results to a CSV file.
There seems to be hundreds of data points at each location so taking the
surface points only could thin it out considerably. It may still take some
time but if its a one-off...

Barry


On Thu, Apr 11, 2019 at 9:57 PM Edzer Pebesma <[hidden email]>
wrote:

> It's a 30 Gb 3D point file:
>
> $ ogrinfo EMU.gpkg
> INFO: Open of `EMU.gpkg'
>       using driver `GPKG' successful.
> 1: EMU_Master (3D Point)
>
> @Shaun: homebrew seems to be supported neither by apple, nor by CRAN, so
> you are a bit on your own there. Have you tried the CRAN binary packages
> using GDAL?
>
> In any case, the windows binary does (should) support gpkg, see
> https://github.com/rwinlib/gdal2
>
> Trying to read this file into R with sf::st_read will require a lot of
> RAM, or some strategy to read in parts only.
>
> On 4/11/19 5:52 PM, Shaun Walbridge wrote:
> > I think the issue is, most GDAL installations don't have the Geopackage
> raster driver [1] installed by default, which lists "Needs libsqlite3 (and
> any or all of PNG, JPEG, WEBP drivers)" for it to be available. At least on
> my Homebrew installation of GDAL, this driver wasn't built out of the box.
> If you rebuild GDAL with this additional driver, or find a prebuilt binary
> which has it, it should be able to open. A simple test is if `gdalinfo
> EMU.gpkg` returns information about the dataset outside of R.
> >
> > 1.
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=
> >
> > On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]>
> wrote:
> >
> >     What did you try? The instructions at the top say:
> >
> >     "Download 3.3GB tile package and rename extension from .tpk to .zip.
> >     Extract to get EMU.gpkg"
> >
> >     If that's a valid GeoPackage then `sf` should be able to read it.
> Not sure
> >     what might be in the geopackage though, "tile package" sounds like
> rasters,
> >     but GeoPackages are generally vector...
> >
> >     I'll try in five minutes when all 3.3Gb have downloaded....
> >
> >     On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino <
> [hidden email]>
> >     wrote:
> >
> >     > Hi,
> >     >
> >     > I would like to open (and use) a 'tpk' file from arcgis in r.
> >     > For example:
> >     >
> >     >
> https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
> >     >
> >     > I tried raster and sf package, but no luck.
> >     >
> >     > Any ideia if we can do this in r?
> >     >
> >     > Thank you very much in advance,
> >     >
> >     > Best wishes,
> >     > M.
> >     >
> >     >         [[alternative HTML version deleted]]
> >     >
> >     > _______________________________________________
> >     > R-sig-Geo mailing list
> >     > [hidden email]
> >     >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
> >     >
> >
> >       [[alternative HTML version deleted]]
> >
> >     _______________________________________________
> >     R-sig-Geo mailing list
> >     [hidden email]
> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
> >
> >
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [hidden email]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Edzer Pebesma
> Institute for Geoinformatics
> Heisenbergstrasse 2, 48151 Muenster, Germany
> Phone: +49 251 8333081
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

edzer
Thanks; not sure this is what is intended, but it seemed to work:

> library(sf)
Linking to GEOS 3.7.0, GDAL 2.4.0, PROJ 5.2.0
> r = st_read("EMU.gpkg", query =
    "select * from EMU_Master where depth_lvl = 1")
Reading layer `EMU_Master' from data source
`/home/edzer/Downloads/EMU.gpkg' using driver `GPKG'
Simple feature collection with 677109 features and 33 fields
geometry type:  POINT
dimension:      XYZ
bbox:           xmin: -179.875 ymin: -78.375 xmax: 179.875 ymax: 89.875
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
> object.size(r)
438817848 bytes


On 4/12/19 12:48 AM, Barry Rowlingson wrote:

> QGIS could "read" it pretty smartly, only loading in the bits in the
> current view extent, and doing the loading in a separate thread so the
> GUI was still active.
>
> Marta has told me that she only needs the surface layer points - the X Y
> and Z coordinates are duplicated as attributes so I think a selection of
> Z=0 (or something) might make a small enough subset to read into R
> directly. This might be doable via the `query` option of `st_read`, or
> failing that a "select" in SQLite3 and dumping the results to a CSV
> file. There seems to be hundreds of data points at each location so
> taking the surface points only could thin it out considerably. It may
> still take some time but if its a one-off...
>
> Barry
>
>
> On Thu, Apr 11, 2019 at 9:57 PM Edzer Pebesma
> <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>     It's a 30 Gb 3D point file:
>
>     $ ogrinfo EMU.gpkg
>     INFO: Open of `EMU.gpkg'
>           using driver `GPKG' successful.
>     1: EMU_Master (3D Point)
>
>     @Shaun: homebrew seems to be supported neither by apple, nor by CRAN, so
>     you are a bit on your own there. Have you tried the CRAN binary packages
>     using GDAL?
>
>     In any case, the windows binary does (should) support gpkg, see
>     https://github.com/rwinlib/gdal2
>
>     Trying to read this file into R with sf::st_read will require a lot of
>     RAM, or some strategy to read in parts only.
>
>     On 4/11/19 5:52 PM, Shaun Walbridge wrote:
>     > I think the issue is, most GDAL installations don't have the
>     Geopackage raster driver [1] installed by default, which lists
>     "Needs libsqlite3 (and any or all of PNG, JPEG, WEBP drivers)" for
>     it to be available. At least on my Homebrew installation of GDAL,
>     this driver wasn't built out of the box. If you rebuild GDAL with
>     this additional driver, or find a prebuilt binary which has it, it
>     should be able to open. A simple test is if `gdalinfo EMU.gpkg`
>     returns information about the dataset outside of R.
>     >
>     > 1.
>     https://urldefense.proofpoint.com/v2/url?u=https-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e=
>     >
>     > On 4/11/19, 11:41 AM, "Barry Rowlingson" <[hidden email]
>     <mailto:[hidden email]>> wrote:
>     >
>     >     What did you try? The instructions at the top say:
>     >     
>     >     "Download 3.3GB tile package and rename extension from .tpk to
>     .zip.
>     >     Extract to get EMU.gpkg"
>     >     
>     >     If that's a valid GeoPackage then `sf` should be able to read
>     it. Not sure
>     >     what might be in the geopackage though, "tile package" sounds
>     like rasters,
>     >     but GeoPackages are generally vector...
>     >     
>     >     I'll try in five minutes when all 3.3Gb have downloaded....
>     >     
>     >     On Thu, Apr 11, 2019 at 3:37 PM Marta Rufino
>     <[hidden email] <mailto:[hidden email]>>
>     >     wrote:
>     >     
>     >     > Hi,
>     >     >
>     >     > I would like to open (and use) a 'tpk' file from arcgis in r.
>     >     > For example:
>     >     >
>     >     >
>     https://esri.maps.arcgis.com/home/item.html?id=24885cd6bd9544f5a8e15d0bf40f67d6
>     >     >
>     >     > I tried raster and sf package, but no luck.
>     >     >
>     >     > Any ideia if we can do this in r?
>     >     >
>     >     > Thank you very much in advance,
>     >     >
>     >     > Best wishes,
>     >     > M.
>     >     >
>     >     >         [[alternative HTML version deleted]]
>     >     >
>     >     > _______________________________________________
>     >     > R-sig-Geo mailing list
>     >     > [hidden email] <mailto:[hidden email]>
>     >     >
>     https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
>     >     >
>     >     
>     >       [[alternative HTML version deleted]]
>     >     
>     >     _______________________________________________
>     >     R-sig-Geo mailing list
>     >     [hidden email] <mailto:[hidden email]>
>     >   
>      https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dsig-2Dgeo&d=DwICAg&c=n6-cguzQvX_tUIrZOS_4Og&r=YFaRLkcUCdDkLrpTbNOUV9J1CwYBCTMwgm5tdQkRSm4&m=nytIIxO936Ls0xrd3zZkBd1WNjQB3DwlOK88GErq19M&s=uahwJjXmsZFnUVQXvkICr3EfAbNjOuaXl6iwziIexTM&e=
>     >     
>     >
>     >
>     > _______________________________________________
>     > R-sig-Geo mailing list
>     > [hidden email] <mailto:[hidden email]>
>     > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>     >
>
>     --
>     Edzer Pebesma
>     Institute for Geoinformatics
>     Heisenbergstrasse 2, 48151 Muenster, Germany
>     Phone: +49 251 8333081
>     _______________________________________________
>     R-sig-Geo mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

pEpkey.asc (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

Martocas
In reply to this post by Roger Bivand
Hi,

Thank you all very much!
This list is amazing.

Barry proposed a way to do it using "SQLite3" (which I did not knew) and
then kindly send me the top layer as a cvs file. After, it is ok to open it
directly, either as a raster or sf (points). I managed that alright.
If anyone else is interested, please send me an email I can forward his
code (with his permission, of course).
Edzer, I will try that on Monday with a pc with available space, although
my smaller experiences already gave error working in the Mac.

Once I manage, I will add it to the rpub file after (
https://rpubs.com/MRufino/485396).

Now, the next issue will be how to transform the huge world wide sf points
(that are actually 32 classes) into a 'multipolygons' sf. Maybe I should do
a new post with a reproducible example for this new challenge, if I don't
manage (tried st_cast to LINESTRING and POLYGON and rasterToPolygons but no
luck).

So, thank you once again,
Good weekend,
Cheers,
M.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

Barry Rowlingson-3
On Fri, Apr 12, 2019 at 6:16 PM Marta Rufino <[hidden email]>
wrote:

> Hi,
>
> Now, the next issue will be how to transform the huge world wide sf points
> (that are actually 32 classes) into a 'multipolygons' sf. Maybe I should do
> a new post with a reproducible example for this new challenge, if I don't
> manage (tried st_cast to LINESTRING and POLYGON and rasterToPolygons but no
> luck).
>
>
 You might be able to polygonize the raster version of the data using
rasterToPolygons (it returns sp class polygons but they can be converted).

...yup - starting with the raster I constructed previously:

takes a couple of minutes....

> rdpoly = rasterToPolygons(rdraster,dissolve=TRUE)
Loading required namespace: rgeos
> rdpoly
class       : SpatialPolygonsDataFrame
features    : 32
extent      : -180, 180, -78.5, 90  (xmin, xmax, ymin, ymax)
coord. ref. : NA
variables   : 1
names       : layer
min values  :     1
max values  :    32
> plot(rdpoly)
> spplot(rdpoly,"layer")

and you'll have to run it yourself to see the results!

 Feel free to share my SQL scripts and other bits of code.

Barry



> So, thank you once again,
> Good weekend,
> Cheers,
> M.
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: tpk files

Martocas
In reply to this post by Martocas
Hi,

Finally, the full code that works
Thanks to everybody once again,

Cheers,
M.

# From Edzer Pebesma (thank you) - see also the alternative from Barry
using sqlite3
library(sf)
#open subset the file depth=1
system.time(r.d1 <- st_read("D:/EMU_Z_Opendata/EMU.gpkg", query = "select *
from EMU_Master where depth_lvl = 1"))

# Code chunks copied from below (adapted with the help of Barry Rowlingson):
require(dplyr)
dr <- r.d1 %>%
  dplyr::rename("x"=POINT_X,"y"=POINT_Y) %>%
  dplyr::mutate(NameEMUn = as.numeric(NameEMU)) %>%
  dplyr::select(x,y, NameEMUn) %>%
  st_set_geometry(NULL)

drz <- rasterFromXYZ(dr)
system.time(drzp <- rasterToPolygons(drz,dissolve=TRUE))
# spplot(drzp,"layer")

emu <- st_as_sf(drzp)
st_crs(emu)=4326
emu$NameEMU = levels(d$NameEMU)
plot(emu)
## Allright!!!
# Export as a shape file:
# write_sf(emu, "emu.shp")

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo