The Q-value is one of the parameters controlling attenuation of seismic waves with distance. Attenuation relations in crust used in the earthquake engineering applications usually consider models with uniform Q and geometrical spreading. In this work we try to estimate a nonuniform Q-value based on the ray geometrical spreading in a nonuniform velocity model. We estimate Q-values in the seismogenic and aseismic zones of the Kinki region (Japan) using Hi-net data. The Hi-net network consists of high-sensitivity seismometers in 100-200 m boreholes. We assumed a two-layer model of Q(f) (seismogenic and aseismic zones), with uniform Q in each layer, and we applied a method for the separation of source, path, and site effects. Path lengths in the layers were calculated using raytracing. A geometrical spreading term was calculated for a realistic 1D velocity model (consisting of three layers over the Moho). Inversion was performed in two steps. (1) The Q value in the seismogenic layer was estimated using shallow earthquake data (depth < 20 km), assuming a one-layer Q model. (2) Data from subduction zone earthquakes covering the aseismic zone (with depths 20-70 km) and two-layer Q model (0-20 and 20-70 km) were used to calculate Q in the aseismic zone, where the Q-value for the upper layer was constrained by results of step 1. The total number of records used was 628. Only direct S-wave data were used to calculate Fourier amplitude spectra in the high-frequency range 1-10 Hz. Validation of the method and inversion results were made by inversion of synthesized data. We discuss in detail several possible sources of errors of the estimation of Q-values. The results of inversion showed a higher Q in the upper layer, Q(f) = 180f0.7 for the seismogenic layer, than that in the lower, Q(f) = 90f0.8 for the aseismic zone. This result supports the model of the crust containing a brittle seismogenic layer and a ductile aseismic zone. We proposed amplitude versus distance attenuation model for Kinki region, Japan, based on estimated Q-values and geometrical spreading.