Ironholds / rgeolocate

Generalised IP geolocation through R
https://cran.r-project.org/web/packages/rgeolocate/index.html
Other
66 stars 22 forks source link

Error: The geolocation database could not be opened - GeoLite2-City.mmdb #24

Closed wabecerra closed 8 years ago

wabecerra commented 8 years ago

Hello,

When I try the following:

library(rgeolocate) file <- system.file("extdata","GeoLite2-Country.mmdb", package = "rgeolocate") results <- maxmind("196.200.60.51", file, c("continent_name", "country_code", "country_name"))

as this website shows: https://cran.r-project.org/web/packages/rgeolocate/vignettes/Introduction_to_rgeolocate.html

It works just fine. However, when I try to read the other Data Base offered at: http://dev.maxmind.com/geoip/geoip2/geolite2/ called: GeoLite2 City

R throws the following error: The geolocation database could not be opened.

Any ideas why this happens?

Regards,

Ironholds commented 8 years ago

The binary or the CSV? Could you provide the code?

wabecerra commented 8 years ago

The binary.

2016-01-12 16:22 GMT-05:00 Oliver Keyes notifications@github.com:

The binary or the CSV?

— Reply to this email directly or view it on GitHub https://github.com/Ironholds/rgeolocate/issues/24#issuecomment-171059235 .

Ironholds commented 8 years ago

Cool! And the code?

wabecerra commented 8 years ago

This is the code I use:

library(rgeolocate);

setwd("mypath");

file <- system.file("extdata","GeoLite2-City.mmdb", package = "rgeolocate") object <- maxmind(as.character(listObj), file, c("continent_name"))

2016-01-12 16:43 GMT-05:00 Oliver Keyes notifications@github.com:

Cool! And the code?

— Reply to this email directly or view it on GitHub https://github.com/Ironholds/rgeolocate/issues/24#issuecomment-171067613 .

Ironholds commented 8 years ago

The fact that the example in the package points to the country database is deliberate; the country database is shipped with the R package. The city database is not, because it's much larger and CRAN doesn't like it when your package is hundreds of megabytes in size.

If you want to use the city databases you should download the city databases and point to those as the file argument. At the moment if you inspect "file" I expect you'll find an empty character vector, because the file you've requested simply doesn't exist - hence why it can't be opened.

I'll distinctly work on improving the documentation to make this clear.

Uriel-Carrasquilla commented 2 years ago

I copied the Enterprise mmdb (from MaxMind) in the .../regeolocate/extdata folder. Did a "chmod" to match the other mmdb. Issued the "file<-system.file("extdata","GeoIP2-Enterprise.mmdb", package = "rgeolocate") The "file" shows the correct file. It works except that the "asn" cannot be retrieved. I know it is there because when I inspect the database, I can see the field under "autonomous_system_number" as shown next:

uriel@urielhpc:~/inspect_maxmind/mmdbinspect_0.1.1_linux_386$ ./mmdbinspect -db ~/geoip/GeoIP2-Enterprise.mmdb 196.200.60.51 [ { "Database": "/home/uriel/geoip/GeoIP2-Enterprise.mmdb", "Records": [ { "Network": "196.200.60.51/24", "Record": { "continent": { "code": "AF", "geoname_id": 6255146, "names": { "de": "Afrika", "en": "Africa", "es": "África", "fr": "Afrique", "ja": "アフリカ", "pt-BR": "África", "ru": "Африка", "zh-CN": "非洲" } }, "country": { "confidence": 99, "geoname_id": 2453866, "iso_code": "ML", "names": { "de": "Mali", "en": "Mali", "es": "Mali", "fr": "Mali", "ja": "マリ共和国", "pt-BR": "Mali", "ru": "Мали", "zh-CN": "马里" } }, "location": { "accuracy_radius": 50, "latitude": 17, "longitude": -4, "time_zone": "Africa/Bamako" }, "registered_country": { "geoname_id": 2453866, "iso_code": "ML", "names": { "de": "Mali", "en": "Mali", "es": "Mali", "fr": "Mali", "ja": "マリ共和国", "pt-BR": "Mali", "ru": "Мали", "zh-CN": "马里" } }, "traits": { "autonomous_system_number": 36864, "autonomous_system_organization": "AFRIBONE MALI SA", "connection_type": "Cable/DSL", "domain": "univ-bamako.edu.ml", "isp": "Afribone Mali SA", "organization": "Afribone Mali SA", "user_type": "residential" } } } ], "Lookup": "196.200.60.51" } ]


and From R, it does not retrieve the "asn" as shown next:

file <- system.file("extdata","GeoIP2-Enterprise.mmdb", package = "rgeolocate") file [1] "/home/uriel/R/x86_64-pc-linux-gnu-library/4.0/rgeolocate/extdata/GeoIP2-Enterprise.mmdb" maxmind("196.200.60.51", file, c("continent_name", "country_code", "city_name", "latitude", "longitude","asn")) continent_name country_code city_name latitude longitude asn 1 Africa ML 17 -4 NA