{ "info": { "author": "toddkarin", "author_email": "pvtools.lbl@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# global-land-mask\nCheck whether a lat/lon point is on land for any point on earth.\n\n# Description\nThis python module, global-land-mask, contains scripts for checking whether a lat/lon point is on land or sea. In order to do this, we use the GLOBE dataset, which samples the entire earth at 1 km resolution. We then simply extract all 'invalid' values from this elevation map and save to file.\n\nThe global mask is of shape (21600, 43200), equating to about 980 mB when saved without compression. This data can be compressed to 2.5 mb using numpy savez_compressed, making for a very compact package.\n\nThe raw elevation data from the GLOBE dataset can be downloaded from \nhttps://www.ngdc.noaa.gov/mgg/topo/gltiles.html\nIt is not necessary to download this data in order to use the global land mask. However, by downloading one can build a global elevation dataset using the functions provided.\n\nThis package provides globe.is_land(), an alaternative to Basemap.is_land(). For 10,000 data points, globe.is_land is around 6000 times faster than Basemap.is_land.\n\n# Simple example\n\nHere is a simple example showing the use of global_land_mask to check if lat/lon points are on land.\n```python\nfrom global_land_mask import globe\nimport numpy as np\n\n# Check if a point is on land:\nlat = 40\nlon = -120\nis_on_land = globe.is_land(lat, lon)\n\nprint('lat={}, lon={} is on land: {}'.format(lat,lon,is_on_land))\n# lat=40, lon=-120 is on land: True\n\n# Check if several points are in the ocean\nlat = 40\nlon = np.linspace(-150,-110,3)\nis_in_ocean = globe.is_ocean(lat, lon)\nprint('lat={}, lon={} is in ocean: {}'.format(lat,lon,is_in_ocean))\n# lat=40, lon=[-150. -130. -110.] is in ocean: [ True True False]\n\n```\n\n# Speed test\n\nCompare performance of global_land_mask and Basemap.\n```python\nfrom global_land_mask import globe\nfrom mpl_toolkits.basemap import Basemap\nimport matplotlib\nmatplotlib.use('TkAgg')\nimport numpy as np\nimport time\n\n\n# Lat/lon points to get\nlat = np.linspace(-20,50,100)\nlon = np.linspace(-130,-70,100)\n\n# Make a grid\nlon_grid, lat_grid = np.meshgrid(lon,lat)\n\n# Get whether the points are on land using globe.is_land\nstart_time = time.time()\nglobe_land_mask = globe.is_land(lat_grid, lon_grid)\nglobe_run_time = time.time()-start_time\nprint('Time to run globe.is_land(): {}'.format(globe_run_time))\n\n# Get whether the points are on land using Basemap.is_land\n# bm = Basemap(projection='cyl',resolution='i')\nbm = Basemap(projection='cyl', llcrnrlat=-60, urcrnrlat=90, \\\n llcrnrlon=-180, urcrnrlon=180, resolution='c')\nf = np.vectorize(bm.is_land)\n\nstart_time = time.time()\nxpt, ypt = bm( lon_grid, lat_grid)\nbasemap_land_mask = f(xpt,ypt)\nbasemap_run_time = time.time()-start_time\nprint('Time to run Basemap.is_land(): {}'.format(basemap_run_time))\n\nprint('Speed up: {}'.format(basemap_run_time/globe_run_time))\n\n# Check agreement (note there is a different treatment for lakes\nfraction_agreed = np.sum(globe_land_mask == basemap_land_mask)/len(globe_land_mask.flatten())\nprint('Fraction agreeing: {}'.format(fraction_agreed))\n```\n\n# Example of map over US\n\nTry running\n\n```python\nfrom global_land_mask import globe\nfrom mpl_toolkits.basemap import Basemap\nimport numpy as np\nimport matplotlib\nmatplotlib.use('TkAgg')\nimport matplotlib.pyplot as plt\n\n\n# Lat/lon points to get\nlat = np.linspace(-20,90,1000)\nlon = np.linspace(-130,-60,1002)\n\n# Make a grid\nlon_grid, lat_grid = np.meshgrid(lon,lat)\n\n# Get whether the points are on land.\nz = globe.is_land(lat_grid, lon_grid)\n\n# Set up map\nfig = plt.figure(0, figsize=(5.5, 4.5))\nplt.clf()\nax = fig.add_axes([0.1, 0.1, 0.8, 0.8])\n\nm = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64, urcrnrlat=49,\n projection='lcc', lat_1=33, lat_2=45, lon_0=-95,\n area_thresh=200,\n resolution='i')\nm.drawstates(linewidth=0.2)\nm.drawcoastlines(linewidth=0.2)\nm.drawcountries(linewidth=0.2)\n\n\ncs = m.contourf(lon_grid, lat_grid, z,\n levels=[-0.5, 0.5,1.5],\n cmap=\"jet\",\n latlon=True)\nplt.show()\n\nplt.savefig('example_plot_globe_map_us.png',\n bbox_inches='tight',\n dpi=400)\n\n```\n\nto create the binary mask for the US, shown in the image below:\n\n![Map of Land Mask](https://github.com/toddkarin/global-land-mask/blob/master/global_land_mask/example_plot_globe_map_us.png \"Map of Land Mask\")\n\nNote that lakes are included as \"on land\" and the resolution isn't perfect, but it's good enough for many purposes!\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/toddkarin/global-land-mask", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "global-land-mask", "package_url": "https://pypi.org/project/global-land-mask/", "platform": "", "project_url": "https://pypi.org/project/global-land-mask/", "project_urls": { "Homepage": "https://github.com/toddkarin/global-land-mask" }, "release_url": "https://pypi.org/project/global-land-mask/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Check whether a lat/lon point in on land or on sea", "version": "0.0.3" }, "last_serial": 5314207, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "f6ee5865853ab6c06ad97dc08b092859", "sha256": "1f0e4f41ad5624dc222809f7c52639bfabbf81fe6044641636aa52a63baf9d71" }, "downloads": -1, "filename": "global_land_mask-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f6ee5865853ab6c06ad97dc08b092859", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10996, "upload_time": "2019-05-24T19:18:46", "url": "https://files.pythonhosted.org/packages/da/a1/e7358e177f26f583cc08dc89456b9760addf7f98b0eca0e05f97bd41d289/global_land_mask-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a90200207398366f748fe5d6f6dba5f6", "sha256": "d893a2b92294c522be3b4f96ee9e6a5df53e15a0fcf6dd803e5040685de0bece" }, "downloads": -1, "filename": "global-land-mask-0.0.1.tar.gz", "has_sig": false, "md5_digest": "a90200207398366f748fe5d6f6dba5f6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5994, "upload_time": "2019-05-24T19:18:48", "url": "https://files.pythonhosted.org/packages/1e/53/20d44114649c48f1f02e75d65a7ef2416639adaa37ba5ab5243af3c8e25a/global-land-mask-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "3409d380e506294e66b20af13a89d4f9", "sha256": "1e32e0ba60aee16058866011c6e27e9209eff6b14b5dcb565196b214d693c272" }, "downloads": -1, "filename": "global_land_mask-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "3409d380e506294e66b20af13a89d4f9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 1836778, "upload_time": "2019-05-24T19:37:14", "url": "https://files.pythonhosted.org/packages/b0/0d/df5c9dbd0e339407cea259867d67d6d9b0959a7b67e900b463131f9b90d3/global_land_mask-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e487421896537201f57595b0da287b37", "sha256": "15f3ebd0fc323844be459c781cd0d8a1cd5daa25d6e9949bf0369703373d39b7" }, "downloads": -1, "filename": "global-land-mask-0.0.2.tar.gz", "has_sig": false, "md5_digest": "e487421896537201f57595b0da287b37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1827774, "upload_time": "2019-05-24T19:37:18", "url": "https://files.pythonhosted.org/packages/22/cf/3ae1e7aa0114917809a93f127dfcab2df84b36a1c40b9354fe3e5a7f4298/global-land-mask-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "933f9c5da9518870d0babca66247bc10", "sha256": "7f3e2b0be2d4928d68b88a1a144b629c1a8af127cc95573a731b92d6da5046b8" }, "downloads": -1, "filename": "global_land_mask-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "933f9c5da9518870d0babca66247bc10", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 1836780, "upload_time": "2019-05-24T19:37:16", "url": "https://files.pythonhosted.org/packages/8b/d8/7d92ea18480abb6d006a412ee6dd5d282f7282ac5e107bd3b4dae44fec94/global_land_mask-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cf366df33bff6bee644629e856672576", "sha256": "b6c31370623f8480a4c2d8330534c7d5993bb7b72935cfbcf227aea97952b634" }, "downloads": -1, "filename": "global-land-mask-0.0.3.tar.gz", "has_sig": false, "md5_digest": "cf366df33bff6bee644629e856672576", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1827772, "upload_time": "2019-05-24T19:37:20", "url": "https://files.pythonhosted.org/packages/cf/37/e7f7127dfb242683c214989a5b7ba403379cb1482cb340fed01a88f0a45d/global-land-mask-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "933f9c5da9518870d0babca66247bc10", "sha256": "7f3e2b0be2d4928d68b88a1a144b629c1a8af127cc95573a731b92d6da5046b8" }, "downloads": -1, "filename": "global_land_mask-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "933f9c5da9518870d0babca66247bc10", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 1836780, "upload_time": "2019-05-24T19:37:16", "url": "https://files.pythonhosted.org/packages/8b/d8/7d92ea18480abb6d006a412ee6dd5d282f7282ac5e107bd3b4dae44fec94/global_land_mask-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cf366df33bff6bee644629e856672576", "sha256": "b6c31370623f8480a4c2d8330534c7d5993bb7b72935cfbcf227aea97952b634" }, "downloads": -1, "filename": "global-land-mask-0.0.3.tar.gz", "has_sig": false, "md5_digest": "cf366df33bff6bee644629e856672576", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1827772, "upload_time": "2019-05-24T19:37:20", "url": "https://files.pythonhosted.org/packages/cf/37/e7f7127dfb242683c214989a5b7ba403379cb1482cb340fed01a88f0a45d/global-land-mask-0.0.3.tar.gz" } ] }