[US] Fwd: Re help with parsing grc/grd files in python

Venkat Gorripati gvenkat72 at gmail.com
Thu Sep 3 12:22:26 PDT 2020


Hi



I am trying to parse some .grc/.grd/.tab files (mapinfo Gis tool files) and
get some data as data-frame and write to Hive



One of my colleague wrote this in R



He is using rgdal and raster libraries



Here is his code to process grc file



parse_grc <- function(file_name){



tab_grc <- raster(paste0(file_name, ".grc"))

grc_data <- as.data.frame(rasterToPoints(tab_grc))

coordinates(grc_data) <- ~x+y

crs(grc_data) <- crs(tab_grc)

grc_data <- spTransform(grc_data, CRS("+proj=longlat +datum=WGS84"))

site_info <- as.data.frame(tab_grc at data@attributes)



grc_data %>%

  as.tibble() %>%

  rename(id = contains(".")) %>%

  inner_join(site_info, c("id" = "ID")) %>%

  select(-id) %>%

  rename(sector = category) %>%

  mutate(flname = file_name) %>%

  separate(flname, into = c("type", "mkt", "band"),

           sep = "-", remove = TRUE) -> grc_df



return(grc_df)

}



In Python , I am using gdal , but Did not find the API’s like the once in R



Do you know any other libraries in Python that are close to rasters library
in R



Any direction is much appreciated



Thanks

-Venkat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/us/attachments/20200903/58942563/attachment.html>


More information about the US mailing list