官术网_书友最值得收藏!

  • Practical GIS
  • Gábor Farkas
  • 277字
  • 2021-07-02 22:49:15

Preparing our data

From the currently opened vector layers, the GeoNames layer has the largest attribute table with the most kinds of attributes. However, as the extract does not contain headers, it is quite hard to work with it. Fortunately, CSV files can be edited as regular text files or as spreadsheets. As the first step, let's open the GeoNames file with a text editor and prepend a header line to it. It is tab delimited; therefore, we need to separate the field names with tabs. The field names can be read out from the readme file in order. In the end, we should have a first line looking something like this:

    geonameid name asciiname alternatenames latitude longitude
featureclass
featurecode countrycode cc2 admin1 admin2 admin3 admin4 population
elevation
dem timezone modification
If you use a text or code editor which replaces tabs with spaces, don't forget to switch off that feature before adding the header line. Furthermore, copy-pasting the preceding code block will probably not work.

Now we can remove our GeoNames layer from the layer tree and add it again. In the form, we have to check the option First record has field names. If we do so, and name the latitude and longitude fields accordingly, we can see QGIS automatically filling the X and Y fields:

You can speed up rendering and spatial querying by checking  Use spatial index. It will consume some memory though, so be careful with unusually large files. If you have such a big GeoNames layer that you cannot work with (like the whole U.S. table on a weaker computer), you can choose another layer for the next part.
主站蜘蛛池模板: 原阳县| 长子县| 三门峡市| 鞍山市| 武山县| 锦屏县| 托克托县| 清水县| 古交市| 霍邱县| 姜堰市| 盐城市| 潼南县| 澜沧| 台州市| 繁峙县| 浦北县| 桓仁| 漯河市| 台东市| 榆树市| 金乡县| 宜昌市| 鲁甸县| 镇沅| 台北市| 土默特左旗| 营山县| 潍坊市| 昌黎县| 时尚| 营口市| 大庆市| 阿荣旗| 昌邑市| 莱阳市| 周口市| 太康县| 江都市| 波密县| 乌审旗|